using MemoryPack;

namespace Game.Networking.Server {
	public class C_FileRemoveRequestMessageHandler : BaseClientMessageHandler {

		public override ClientPacketID CommandId {
			get {
				return ClientPacketID.ProgramFileDeleteRequest;
			}
		}

		public override void ProcessMessage(ClientState client, byte[] rawCommand) {
			var command = MemoryPackSerializer.Deserialize<C_FileRemoveRequestMessage > (rawCommand);
			var unit = ServerScriptController.Instance.GetUnitById(client.UnitId);
			if ( unit == null ) {
				return;
			}
			unit.RemoveSourceCode(command.FileName);
		}
	}
}
